//
//  AXFGoodsTableViewCell.m
//  AIXF
//
//  Created by Macx on 2017/7/13.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFGoodsTableViewCell.h"
#import "AXFAccountManager.h"
@interface AXFGoodsTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *increaseBtn;
@property (weak, nonatomic) IBOutlet UIButton *reduseBtn;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@end

@implementation AXFGoodsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
   
}

- (IBAction)increaseAction:(id)sender
{
    
    _model.count++;
    
    _AXFAccountManager.goodsNum++;
    
       [[NSNotificationCenter defaultCenter] postNotificationName:kIncrementGoodsNumNotification object:nil];
}
- (IBAction)reduseAction:(id)sender
{
    _model.count--;
    
     _AXFAccountManager.goodsNum--;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kIncrementGoodsNumNotification object:nil];
}

- (void)setModel:(AXFHomeFirstSellModel *)model
{
    _model = model;
    
    _nameLabel.text = model.name;
    
    _countLabel.text = [NSString stringWithFormat:@"%d",model.count];
    
    CGFloat  price = [model.price floatValue] * model.count;
    
    _priceLabel.text = [NSString stringWithFormat:@"%.2f",price];
    
}

@end
